<!DOCTYPE html>
<html lang="en"
      xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <script src="/js/rem.js" type="text/javascript"></script>
    <meta content="yes" name="apple-mobile-web-app-capable">
    <meta content="telephone=no" name="format-detection">
    <meta content="black" name="apple-mobile-web-app-status-bar-style">
    <link rel="stylesheet" href="/css/common.css" type="text/css">

    <link rel="stylesheet" href="/css/record.css" type="text/css">
    <title>录音</title>
    <style>

        @keyframes loading{
            0%{
                transform: rotate(0deg);
            }
            100%{
                transform: rotate(360deg);
            }
        }
        .loading{
            animation: loading 2s linear infinite;
        }
    </style>
</head>
<body>
<div id="record_main">
    <div class="record_content">

        <!--<input id="acticleurl" type="hidden" th:value="${article.getARTICLE_URL()}"/>-->
        <!--<div class="record_article">-->
            <!--<iframe width="100%" height="100%" th:src=" "  frameborder="no" border="0"></iframe>-->
        <!--</div>-->
        <div class="record_article">
            <iframe width="100%" height="100%" th:src="${article.getARTICLE_URL()}"  frameborder="no" border="0"></iframe>
        </div>

        <!--<div class="pd recpower" style="display: none">-->
            <!--<div style="height:5px;width:100%;background:#999;position:relative;">-->
                <!--<div class="recpowerx" style="height:5px;background:#0B1;position:absolute;"></div>-->
                <!--&lt;!&ndash;<div class="recpowert" style="padding-left:50px; line-height:40px; position: relative;"></div>&ndash;&gt;-->
            <!--</div>-->
        <!--</div>-->


        <!--<div class="recpower"  style="border:1px solid #ccc;display: none"><div style="height:30px;" class="recwave"></div></div>-->


        <div class="record_btn">
            <div class="progress_bar">
                <div></div>
                <span class="progress_bar_time"><span id="cur_time">00:00</span>/<span id="total_time">10:00</span></span>
            </div>
            <div class="record_btn_btn">
                <div class="record_state" style="display: flex;">
                    <!-- 开始 -->
                    <!--<button type="button" class="record_startp" style="display: inline-block"><img-->
                    <!--src="/img/record_start.png"></button>-->
                    <button type="button" class="record_start" style="display: inline-block"><img
                            src="/img/record_start.png"></button>
                </div>
                <div class="record_state">
                    <!-- 重置 -->
                    <button type="button" class="record_refresh"><img src="/img/record_refresh.png"></button>
                    <!-- 继续 -->
                    <button type="button" style="display: none;" class="record_continue"><img src="/img/record_play.png"></button>
                    <!-- 暂停 -->
                    <button type="button" style="display: none;" class="record_pause"><img src="/img/record_stop.png"></button>
                    <!-- 完成 -->
                    <button type="button" class="record_finish"><img src="/img/record_finsh.png"></button>
                </div>
                <div class="record_state">
                    <!-- 重置 -->
                    <button type="button" class="record_refresh"><img src="/img/record_refresh.png"></button>
                    <!-- 试听 -->
                    <audio class="recPlay" style="display: none"></audio>
                    <button type="button" style="display: inline-block;" class="record_listen "><img src="/img/record_listen.png"></button>
                    <!--发布 -->
                    <button type="button" class="record_publish"><img src="/img/record_publish.png"></button>
                </div>
            </div>
        </div>
        <span style="display: none" class="active_id" th:text="${article.getACTIVITY_ID()}"></span>
        <span style="display: none" class="user_id" th:text="${article.getUSER_ID()}"></span>
    </div>
</div>
</body>
<script type="text/javascript" src="/js/zepto.js"></script>
<script type="text/javascript" src="/js/touch.js"></script>
<script src="/js/record/ios-weixin-config.js"></script>
<script src="/js/record/app.js"></script>
<!--<script type="text/javascript" src="./zepto.js"></script>-->
<!--<script type="text/javascript" src="./touch.js"></script>-->
<!--<script src="./ios-weixin-config.js"></script>-->
<!--<script src="./app.js"></script>-->

<script>
    function RandomKey(){
        return "randomkey"+(RandomKey.idx++);
    };
    RandomKey.idx=0;
</script>


<script>
    var isInstall=false;
    (function(){
//注册可选扩展库
        var paths=RecordApp.Platforms.Default.Config.paths;
        paths.push({
            url:RecordAppBaseFolder+"waveview.js"
            ,lazyBeforeStart:1 //开启延迟加载，在Start调用前任何时间进行加载都行
            ,check:function(){return !Recorder.WaveView}
        });

        //可以设置组件是否进行延迟加载，默认会延迟加载，不会阻塞Install
        RecordApp.UseLazyLoad=true;

        //立即加载环境，自动把Recorder加载进来
        RecordApp.Install(function(){
            reclog("RecordApp.Install成功");
            isInstall=true;
            window.onInstall&&onInstall();
        },function(err){
            var msg="RecordApp.Install出错："+err;
            reclog(msg);
            alert(msg);
        });

    })();
</script>

<script>
    //后期改成console.log
    function reclog(s){
        var now=new Date();
        var t=("0"+now.getHours()).substr(-2)
            +":"+("0"+now.getMinutes()).substr(-2)
            +":"+("0"+now.getSeconds()).substr(-2);
        console.log("["+t+']'+s);
    };
    window.onerror=function(message, url, lineNo, columnNo, error){
        reclog('【Uncaught Error】'+message+'<pre>'+"at:"+lineNo+":"+columnNo+" url:"+url+"\n"+(error&&error.stack||"不能获得错误堆栈"));
    };
</script>


<script>

    function baseSet(){
        var alwaysUseWeixinJS=false;//根据需要修改
        if(!!RecordApp.alwaysUseWeixinJSPrev!=alwaysUseWeixinJS){
            reclog("JsSDK选项变更，已重置RecordApp，请先进行权限测试");
            RecordApp.Current=null;
            RecordApp.alwaysUseWeixinJSPrev=alwaysUseWeixinJS;
        };
        RecordApp.AlwaysUseWeixinJS=alwaysUseWeixinJS;
        cancelAutoStop();
    };
    function recreq(success,fail){
        baseSet();
        reclog("开始请求授权...");

        dialogInt=setTimeout(function(){//定时8秒后打开弹窗，主要用于监测浏览器没有发起权限请求的情况，在RequestPermission前放置定时器利于收到了回调能及时取消（不管open是同步还是异步回调的）
            showDialog();
        },8000);

        RecordApp.RequestPermission(function(){
            dialogCancel();
            reclog(RecordApp.Current.Key+"已授权",2);
            success&&success();
        },function(err,isUserNotAllow){
            dialogCancel();
            reclog(RecordApp.Current.Key+(isUserNotAllow?" UserNotAllow，":"")+" 授权失败："+err,1);
            fail&&fail();
        })
    }
    function waitDialogClick(){
        dialogCancel();
        reclog("打开失败：权限请求被忽略，用户主动点击的弹窗");
        $(".LoadingDialog").remove();
    }
    //我们可以选择性的弹一个对话框：为了防止移动端浏览器存在第三种情况：用户忽略，并且（或者国产系统UC系）浏览器没有任何回调
    var showDialog=function(){
        if(!/mobile/i.test(navigator.userAgent)){
            return;//只在移动端开启没有权限请求的检测
        }
        dialogCancel();
        $("body").append(''
            +'<div class="waitDialog" style="z-index:99999;width:100%;height:100%;top:0;left:0;position:fixed;background:rgba(0,0,0,0.3);">'
            +'<div style="display:flex;height:100%;align-items:center;">'
            +'<div style="flex:1;"></div>'
            +'<div style="width:240px;background:#fff;padding:15px 20px;border-radius: 10px;">'
            +'<div style="padding-bottom:10px;">录音功能需要麦克风权限，请允许；如果未看到任何请求，请点击忽略~</div>'
            +'<div style="text-align:center;"><a onclick="waitDialogClick()" style="color:#0B1">忽略</a></div>'
            +'</div>'
            +'<div style="flex:1;"></div>'
            +'</div>'
            +'</div>');
    }
    var dialogInt;
    var dialogCancel=function(){
        clearTimeout(dialogInt);
        $(".waitDialog").remove();
    };
    //弹框End


    var curSet,autoStopTimer;
    function recstartAndAutoStop(){
        var time=+$(".autoStopTime").val()||0;
        if(time<100){
            console.log("定时不能小于100ms",1);
            return;
        };
        recstart(function(msg){
            if(msg){
                msg&&console.log(msg,1);
                return;
            };
            console.log("定时"+time+"ms后自动停止录音");
            autoStopTimer=setTimeout(function(){
                autoStopTimer=0;
                console.log("定时时间到，开始自动调用停止...");
                recstop();
            },time);
        });
    };
    var cancelAutoStop=function(){
        if(autoStopTimer){
            console.log("已取消定时停止",1);
            clearTimeout(autoStopTimer);
            autoStopTimer=0;
        };
    };

    /**
     * 开始录制
     * @param call
     */
    function recstart(call,permit,unpermit){
        call||(call=function(msg){
            msg&&reclog(msg);
        });
        baseSet();
        if(!RecordApp.Current){
            call("需先调用RequestPermission");
            unpermit();//先调用RequestPermission
            return;
        };
        if(RecordApp.Current==RecordApp.Platforms.Weixin){
            reclog("正在使用微信JsSDK，录音过程中不会有任何回调");
        }else{
            reclog("正在使用H5录音，底层由Recorder直接提供支持");
            // $(".recpower").css("display","block");
        };

        var type="mp3";
        var bit="128";
        var sample="22050";
        window.waveView={};
        var set={
            type:type
            ,bitRate:bit
            ,sampleRate:sample
            ,onProcess:function(buffers,powerLevel,duration,sampleRate){
                // $(".recpowerx").css("width",powerLevel+"%");
                // $(".recpowert").text(formatMs(duration,1)+" / "+powerLevel);

                if(waveView&&waveView.input)
                    waveView.input(buffers[buffers.length-1],powerLevel,sampleRate);
            }
        };
        curSet=null;
        reclog(RecordApp.Current.Key+"正在打开...");
        RecordApp.Start(set,function(){
            curSet=set;
            reclog(RecordApp.Current.Key+"已打开:"+type+" "+bit+"kbps",2);
            // waveView=Recorder.WaveView({elem:".recwave"});
            // call();
            permit();//可以正常录音
        },function(err){
            call(RecordApp.Current.Key+"打开失败："+err);
            unpermit();//先调用RequestPermission
        });
    };
    function recstopX(){
        cancelAutoStop();
        RecordApp.Stop(
            null //success传null就只会清理资源，不会进行转码
            ,function(msg){
                reclog("已清理，错误信息："+msg);
            }
        );
    };
    var recblob={};
    function recstop(call,endCall){
        recstopFn(call,true,endCall);

    };

    var Eduration;
    function recstopFn(call,isClick,endCall,rec){
        cancelAutoStop();
        call||(call=function(msg){
            msg&&console.log(msg,1);
        });

        var t1=Date.now();
        if(!isClick){
            rec.stop(function(blob,time){
                var tag=endCall("",blob,time);
                if(tag==-1){
                    return;
                };

                addRecLog(time,tag||"已录制",blob,rec.set,t1);
            },function(s){
                console.log("失败："+s);
                endCall(s);
            });
            return;
        };

        var setData=curSet;
        curSet=null;

        if(!setData){
            //没有开始？不管，stop清理资源
            setData={};
        }else{
            console.log(RecordApp.Current.Key+"正在结束"+setData.type+"...");
            if(RecordApp.Current==RecordApp.Platforms.Weixin){
                reclog("正在使用微信JsSDK，录音过程中不会有任何回调");
            }else{
                reclog("正在使用H5录音，底层由Recorder直接提供支持");
                // $(".recpower").css("display","none");
            };
        };

        RecordApp.Stop(function(blob,time){
            endCall("",blob,time);

            var wxData=setData.DownWxMediaData;//微信JsSDK 下载到的音频源文件
            if(wxData){
                var list=wxData.list;
                delete wxData.list;

                // console.log("<span style='color:#0b1'>发现微信JsSDK录制的源文件，共"+list.length+"段，时间统计："+JSON.stringify(wxData)+"</span>");
                // if(!Recorder.AMR){
                //     console.log("<span style='color:#fb0'>播放需要上面点击换到amr类型，加载amr解码器，目前未加载<span>");
                // };

                var t1x=t1;
                t1=Date.now();
                for(var i=0;i<list.length;i++){
                    var obj=list[i];
                    var bstr=atob(obj.data),n=bstr.length,u8arr=new Uint8Array(n);
                    while(n--){
                        u8arr[n]=bstr.charCodeAt(n);
                    };
                    var blob2=new Blob([u8arr.buffer], {type:obj.mime});
                    // addRecLog(obj.duration,"<span style='color:#0b1'>微信源片段"+(i+1)+"</span>",blob2,{type:/\/(\w+)/.exec(obj.mime)[1]},t1);
                };
                t1=t1x;
            };
            addRecLog(time,"已录制",blob,setData,t1);
            call(null,{data:blob,duration:time});
            // console.log("返回音频1》》》》》",time,"返回音频2》》》》》",blob,"返回音频3》》》》》",setData,"返回音频4》》》》》",t1)
            Eduration = time;

        },function(s){
            endCall(s);
            call("失败："+s);
        });
    };
    var addRecLog=function(time,tag,blob,set,t1){
        var id=RandomKey(16);
        recblob[id]={blob:blob,set:$.extend({},set),time:time};
        recplay(id);
        // console.log(tag+":"+intp(set.bitRate,3)+"kbps "+intp(set.sampleRate,5)+"hz 花"+intp(Date.now()-t1,4)+"ms编码"+intp(blob.size,6)+"b ["+set.type+"]"+formatMs(time)+'ms <button onclick="recdown(\''+id+'\')">下载</button> <button onclick="recplay(\''+id+'\')">播放</button> <span class="p'+id+'"></span> <span class="d'+id+'"></span>');
    };
    var intp=function(s,len){
        s=s==null?"-":s+"";
        if(s.length>=len)return s;
        return ("_______"+s).substr(-len);
    };
    var formatMs=function(ms,all){
        var f=Math.floor(ms/60000),m=Math.floor(ms/1000)%60;
        var s=(all||f>0?(f<10?"0":"")+f+":":"")
            +(all||f>0||m>0?("0"+m).substr(-2)+"″":"")
            +("00"+ms%1000).substr(-3);
        return s;
    };
    var Eblob;
    function recplay(key){
        var o=recblob[key];
        if(o){
            var audio=$(".recPlay")[0];
            audio.controls=true;
            if(!(audio.ended || audio.paused)){
                audio.pause();
            };
            o.play=(o.play||0)+1;
            var logmsg=function(msg){
                $(".p"+key).html('<span style="color:green">'+o.play+'</span> '+new Date().toLocaleTimeString()+" "+msg);
            };
            logmsg("");
            audio.onerror=function(e){
                logmsg('<span style="color:red">播放失败['+audio.error.code+']'+audio.error.message+'</span>');
            };

            var end=function(blob){
                audio.src=(window.URL||webkitURL).createObjectURL(blob);
                Eblob= blob;
            };
            var wav=Recorder[o.set.type+"2wav"];
            if(wav){
                logmsg("正在转码成wav...");
                wav(o.blob,function(blob){
                    end(blob);
                    logmsg("已转码成wav播放");
                },function(msg){
                    logmsg("转码成wav失败："+msg);
                });
            }else{
                end(o.blob);
            };
        };
    };
    function recdown(key){
        var o=recblob[key];
        if(o){
            var cls=RandomKey(16);
            var name="rec-"+o.time+"ms-"+o.set.bitRate+"kbps-"+o.set.sampleRate+"hz."+o.set.type;

            o.down=(o.down||0)+1;
            $(".d"+key).html('<span style="color:red">'+o.down+'</span> 点击 <span class="'+cls+'"> 下载，或复制文本<button onclick="recdown64(\''+key+'\',\''+cls+'\')">生成Base64文本</button></span>');

            var downA=document.createElement("A");
            downA.innerHTML="下载 "+name;
            downA.href=(window.URL||webkitURL).createObjectURL(o.blob);
            downA.download=name;
            $("."+cls).prepend(downA);
            //downA.click(); 某些软件内会跳转页面到恶心推广页
        };
    };
    function recdown64(key, cls){
        var o=recblob[key];

        var reader = new FileReader();
        reader.onloadend = function() {
            var id=RandomKey(16);
            $("."+cls).append('<textarea class="'+id+'"></textarea>');
            $("."+id).val(reader.result);
        };
        reader.readAsDataURL(o.blob);
    };
    console.log("点击录制开始哦");

</script>

<!--<script>-->
    <!--if(/mobile/i.test(navigator.userAgent)){-->
        <!--//移动端加载控制台组件-->
        <!--var elem=document.createElement("script");-->
        <!--elem.setAttribute("type","text/javascript");-->
        <!--elem.setAttribute("src","https://cdn.bootcss.com/eruda/1.5.4/eruda.min.js");-->
        <!--$("head")[0].appendChild(elem);-->
        <!--elem.onload=function(){-->
            <!--eruda.init();-->
        <!--};-->
    <!--};-->
<!--</script>-->


<script>
    function loadEngine(){
        var type="mp3"
        var engines=["mp3","mp3-engine"];
        var end=function(){
            var enc=Recorder.prototype["enc_"+type];
            var tips=[!enc?"这个编码器无提示信息":type+"编码器"+(enc.stable?"稳定版":"beta版")+"，<span style='color:"+(type=="wav"?"#0b1'>wav转码超快":Recorder.prototype[type+"_start"]?"#0b1'>支持边录边转码(Worker)":"red'>仅支持标准UI线程转码")+"</span>，"+enc.testmsg];
            tips.push('<div style="color:green">');
            tips.push("【使用"+type+"录音需要在app.js Platforms.Default内注册】：");
            tips.push("src/recorder-core.js, src/engine/");
            tips.push(engines.join(".js, src/engine/"));
            tips.push(".js</div>");
            reclog(tips.join(""));
        };
        if(!Recorder.prototype[type]){
            reclog("正在加载"+type+"编码器，请勿操作...");
            var i=-1;
            var load=function(){
                i++;
                if(i>=engines.length){
                    reclog(type+"编码器已加载，可以录音了");
                    end();
                    return;
                }
                var elem=document.createElement("script");
                elem.setAttribute("type","text/javascript");
                elem.setAttribute("src",RecordAppBaseFolder+engines[i]+".js");
                elem.onload=function(){
                    load();
                };
                $("head")[0].appendChild(elem);
            };
            load();
        }else{
            end();
        };
    };
    function onInstall(){
        var isApp;
        RecordApp.Platforms.Native.Config.IsApp(function(v){isApp=v;});

        RecordApp.Current.OnLazyReady(function(){
            reclog("OnLazyReady触发，所有组件已完成加载",2);
            loadEngine("mp3");
        });
        reclog("Install成功，环境："+RecordApp.Current.Key+"，可以录音了",2);
    };
    reclog("正在执行Install，请勿操作...");
    if(isInstall){
        onInstall();
    };










    //总时间 单位秒
    var totalTime=600;//可录制总时间 600秒 如果是需要显示 录制的时间 进度条 修改该值即可
    //两个interval 对象
    var timeup;
    //当前的显示的时间 分钟和秒
    var curTime = 0;
    //判断状态 录音 还是 试听
    var IS_RECORDING_STAGE=true;

    function PrefixInteger(num, length) {
        return (Array(length).join('0') + num).slice(-length);
    }

    function StartProgress(){
        //时间变化
        timeup = window.setInterval(function () {
            curTime++;
            if (curTime >= totalTime) {
                PauseProgress();
                //是否 录制状态
                if(IS_RECORDING_STAGE){
                    LoadingDialog();
                    totalTime=curTime;//此处设置录制的时间 假定120秒
                    ResetProgress();
                    recstop(function(){
                        $(".LoadingDialog").remove();
                        $(".record_pause").css("display", "none");
                        $(".record_continue").css("display", "inline-block");
                        //自动进入 试听状态
                        $(".record_finish").parent().css("display","none");
                        $(".record_listen").parent().css("display","flex");
                        if(RecordApp.Current==RecordApp.Platforms.Weixin){
                            reclog("正在使用微信JsSDK，录音过程中不会有任何回调");
                        }else{
                            reclog("正在使用H5录音，底层由Recorder直接提供支持");
                            // $(".recpower").css("display","none");
                        };
                    },function(){

                    })
                }else{ //播放状态
                    $(".record_listen").removeClass("hide_show");
                    isListening=false;
                }
            }
            $(".progress_bar>div").css("width", ((curTime/totalTime) * 100) + "%");
            $("#cur_time").text(PrefixInteger(parseInt(curTime/60), 2) + ":" + PrefixInteger(parseInt(curTime%60), 2))
        }, 1000);
    }

    /*
        清除进度条数据
     */
    function ResetProgress(){
        clearInterval(timeup);
        curTime = 0;
        $(".progress_bar>div").css("width", "0");
        $("#cur_time").text(PrefixInteger(parseInt(curTime/60), 2) + ":" + PrefixInteger(parseInt(curTime/60), 2))
        $("#total_time").text(PrefixInteger(parseInt(totalTime/60), 2) + ":" + PrefixInteger(parseInt(totalTime%60), 2))

    }

    function PauseProgress(){
        clearInterval(timeup);
    }


    //开始录制
    $(".record_start").on("tap", function () {
        var that=this;
        LoadingDialog();
        reclog("开始·············································")
        recstart(null,function(){
            $(".LoadingDialog").remove();
            //有授权
            $(that).parent().css("display", "none");
            $(".record_pause").parent().css("display","flex");
            StartProgress();
            IS_RECORDING_STAGE=true;
            reclog("录音·············································")
        },function(){
            $(".LoadingDialog").remove();
            //无
            showRequestPermissionDialog();
            reclog("无·············································")
        });
        reclog("不知道·············································")




    });
    function permissionDialogPermit(){
        permissionDialogCancel();
        LoadingDialog();

        recreq(function(){
            $(".LoadingDialog").remove();

            alert("获取录音权限成功，点击录音按钮开始录音吧！");
        },function(){
            $(".LoadingDialog").remove();

            alert("获取录音权限失败，这将导致无法进行录音！");
        });
    }

    function showRequestPermissionDialog(){
        $("body").append(''
            +'<div onclick="permissionDialogCancel();" class="permissionDialog" style="z-index:99999;width:100%;height:100%;top:0;left:0;position:fixed;background:rgba(0,0,0,0.3);">'
            +'<div style="display:flex;height:100%;align-items:center;">'
            +'<div style="flex:1;"></div>'
            +'<div style="width:240px;background:#fff;padding:15px 20px;border-radius: 10px;">'
            +'<div style="padding-bottom:10px;">录音功能需要麦克风权限，现在去获取权限。</div>'
            +'<div style="text-align:center;"><a onclick="permissionDialogPermit()" style="color:#0B1">允许</a></div>'
            +'</div>'
            +'<div style="flex:1;"></div>'
            +'</div>'
            +'</div>');
    }
    var permissionDialogCancel=function(){
        $(".permissionDialog").remove();
    };





    //重置 重新录制
    $(".record_refresh").on("tap", function () {
        audio.pause();
        $(this).parent().css("display","none");
        $(".record_continue").css("display", "none");
        $(".record_pause").css("display", "none");
        $(".record_start").parent().css("display","flex");
        totalTime=600;
        ResetProgress();
        //取消试听状态
        $(this).removeClass("hide_show");
        isListening=false;
        recstopX();
        if(RecordApp.Current==RecordApp.Platforms.Weixin){
            reclog("正在使用微信JsSDK，录音过程中不会有任何回调");
        }else{
            reclog("正在使用H5录音，底层由Recorder直接提供支持");
            // $(".recpower").css("display","none");
        };
    });

    //完成 --》进入试听状态
    $(".record_finish").on("tap", function () {

        var that= this
        LoadingDialog();
        totalTime=curTime;//此处设置录制的时间 假定120秒
        ResetProgress();
        // function(err,blob,time){
        //
        // }

        recstop(function(){
            $(".LoadingDialog").remove();
            $(that).parent().css("display","none");
            $(".record_listen").css("display","inline-block");
            $(".record_listen").parent().css("display","flex");
        },function(){

        })




    });

    function LoadingDialog(){
        $("body").append(''
            +'<div class="LoadingDialog" style="z-index:99999;width:100%;height:100%;top:0;left:0;position:fixed;background:rgba(0,0,0,0.3);">'
            +'<div style="position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);width:300px;height:300px;display: flex;justify-content: center;align-items: center;">'
            +'<img src="/img/loading_icon_2.png" class="loading" style="width:100px;height:100px;">'
            +'</div>'
            +'</div>');
    }








    //--------------- 试听 与 暂停试听-------------------
    var audio=$(".recPlay")[0];
    var isListening=false;
    $(".record_listen").on("tap",function () {

        IS_RECORDING_STAGE=false;
        //正在试听...
        if(isListening){
            $(this).removeClass("hide_show");
            isListening=false;
            PauseProgress();
            //TODO 暂停播放
            console.log("暂停播放");
            audio.pause();
        }else{
            if(curTime>=totalTime){
                curTime=0;
                //TODO :重置当前时间为 0
            }
            $(this).addClass("hide_show");
            isListening=true;
            StartProgress();
            //TODO 播放音频
            audio.play();
            console.log("开始播放");
        }

    });
    //发布
    $(".record_publish").on("tap",function(){
        LoadingDialog();
        var formData=new FormData();
        formData.append("file",Eblob,"recorder.mp3");
        var activity_id  = $(".active_id").eq(0).text();
        var user_id  = $(".user_id").eq(0).text();
        $.ajax({
            url:'/front/recordUpload'
            ,type:"post"
            ,contentType:false
            ,processData:false
            ,data:formData
            ,async: false
            ,dataType: "text"
            ,success:function(v){
                $(".LoadingDialog").remove();
                console.log("上传成功",v);
                window.location.href = "/front/uploadRecorder?USER_ID=" + user_id + "&ACTIVITY_ID=" + activity_id +"&RESOURCE_URL=" + v +"&WORK_LENTHs=" +Eduration
            }
            ,error:function(s){
                $(".LoadingDialog").remove();
                alert("发布失败，请重新刷新页面！")
                console.error("上传失败",s);
            }
        });
    })

</script>

</html>